<?php

namespace app\modules\Finance\models;

use Yii;
use app\modules\Order\models\Order;

/**
 * This is the model class for table "invoice_order".
 *
 * @property integer $id
 * @property integer $order_id
 * @property string $order_code
 * @property string $price
 * @property integer $invoice_id
 * @property integer $product_id
 */
class InvoiceOrder extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'invoice_order';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['order_id', 'invoice_id', 'product_id','finance_id'], 'integer'],
            [['price'], 'number'],
            [['order_code'], 'string', 'max' => 16],
        ];
    }

    //  获取对应订单信息
    public function getOrder(){
        
        return $this->hasOne(Order::className(), ['id' => 'order_id']);
    }

    //  获取对应发票信息
    public function getInvoice(){
        
        return $this->hasOne(Invoice::className(), ['id' => 'invoice_id']);
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app.order', 'ID'),
            'order_id' => Yii::t('app.order', 'Order ID'),
            'order_code' => Yii::t('app.order', 'Order Code'),
            'price' => Yii::t('app.order', 'Price'),
            'invoice_id' => Yii::t('app.order', 'Invoice ID'),
            'finance_id' => Yii::t('app.order', 'Finance ID'),
            'product_id' => Yii::t('app.order', 'Product ID'),
        ];
    }
}
